package com.yihuier.yihuier.Service.RoomManager;

import com.yihuier.yihuier.Mapper.RoomManager.CompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class CompanyService {

    @Autowired
    private CompanyMapper companyMapper;

    public Map<String,Object> getRoomToCompanyTimeAndName(int company_id){
        return companyMapper.selectRoomToCompanyTimeAndName(company_id);
    }
    public Date getCompanyDeadline(int company_id){
        return companyMapper.selectCompanyDeadline(company_id);
    }

    /**
     * 添加公司
     * */
    public int addCompanyReturnCompanyId(String company_name,String company_deadline,int advertisement_company){
        int addResult = companyMapper.insertCompany(company_name,company_deadline,advertisement_company);
        if (addResult == 1){
            return  companyMapper.selectCompanyIdWhenRegister(company_name,company_deadline,advertisement_company);
        }
        return 0;
    }

    /**
     * 根据公司id得到公司信息
     * */
    public Map<String,String> getCompanyByCompanyId(Number company_id){
        return companyMapper.selectCompanyByCompanyId(company_id);
    }

    /**
     * 得到所有公司信息
     * */
    public List<Map<String,Object>> getAllCompany(){
        return companyMapper.selectAllCompany();
    }

    /**
     * 修改公司服务时间
     * */
    public int setCompanyServerTime(String company_id,String company_deadline){
        return companyMapper.updateCompanyServerTime(company_id,company_deadline);
    }

    /**
     * 改变公司服务状态
     * */
    public int updateCompanyStatus(int company_id,int company_status){
        return companyMapper.updateCompanyStatus(company_id,company_status);
    }
}
